package com.luych.toolbox.common.feign;

import com.luych.toolbox.common.constant.PageConstant;
import com.luych.toolbox.common.page.CommonPageResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

public interface FeignInterface<View extends FeignView, Param extends FeignParam> {

    @ApiOperation("分页查询")
    @GetMapping
    CommonPageResult<View> page(
            @ApiParam(value = "每页容量") @RequestHeader(name = "pageSize", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SIZE_STR) long pageSize,
            @ApiParam(value = "查询页码") @RequestHeader(name = "pageNumber", required = false, defaultValue = PageConstant.DEFAULT_PAGE_NUMBER_STR) long pageNumber,
            @ApiParam(value = "排序字段") @RequestHeader(name = "sort", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SORT) String sort,
            @ApiParam(value = "正序/倒序，取值ASC/DESC") @RequestHeader(name = "order", required = false, defaultValue = PageConstant.DEFAULT_PAGE_ORDER) String order
    );

    @ApiOperation("按ID查询")
    @GetMapping("/{id}")
    View get(@ApiParam(value = "ID") @PathVariable("id") String id);

    @ApiOperation("新增")
    @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
    View create(@ApiParam(value = "数据信息") @RequestBody Param model);

    @ApiOperation("修改")
    @PutMapping(path = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
    View modify(
            @ApiParam(value = "ID") @PathVariable("id") String id,
            @ApiParam(value = "数据信息") @RequestBody Param model
    );

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    void remove(@ApiParam(value = "ID") @PathVariable("id") String id);

}
